package blockchain.mystream;

import java.io.DataInputStream;
import java.io.IOException;

public interface MyDataInputStreamInterface {
    // 定义一个抽象方法，由实现类提供 DataInputStream 对象
    DataInputStream getDataInputStream();

    // 定义 read 方法
    default String read() throws IOException {
        int len = getDataInputStream().readInt();
        byte[] buffer = new byte[len];
        getDataInputStream().readFully(buffer);
        return new String(buffer);
    }
    default int readInt() throws IOException {
        return getDataInputStream().readInt();
    }
}
